package com.andy.common.base

import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding

/**
 * Author:Andy
 * Date:2023/3/20 16:57
 * Description:BaseVMFragment
 */
abstract class BaseVMFragment<VB : ViewBinding, VM : BaseViewModel> : BaseFragment<VB>() {
    protected open lateinit var mViewModel: VM

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initVM()
        initObserve()
        initData()
        initAction()
    }

    private fun initVM() {
        mViewModel = ViewModelProvider(this)[viewModelClass()]
    }

    abstract fun viewModelClass(): Class<VM>

    abstract fun initObserve()

    abstract fun initData()

    abstract fun initAction()
}